<?php

class paramtersBean 
{
    function paramtersBean()
    {
    }
 
   
	/*
     * Get all buy E-currency Paging
     */
    function countFee($db,$type){
    	$sql = "SELECT COUNT(f.id) as total FROM ".TBL_CURRENCY_FEE." f WHERE f.currency_type = '$type' ";
    	$res = $db->get_row($sql);
    	
    	return $res->total;
    }
	
	function getFeeShare($db,$maxview,$path,$type){
		$page = isset ( $_GET[$path] ) ? intval ( $_GET[$path] ) : 1;
		$rows_per_page= $maxview;
		$page_start = ( $page - 1 ) * $rows_per_page;
		$page_end = $page * $rows_per_page;
	
		$strSQL = "SELECT f.currency_type,f.fee_percent,f.bank_fee,f.bank_currency,f.amount_litmit,e.ecurrency_name,s.bank_name ".
					"FROM ".TBL_CURRENCY_FEE." f ".
					" LEFT JOIN ".TBL_BANK_LIST." s ON f.bank_id = s.bank_id ".
					" LEFT JOIN ".TBL_E_CURRENCY." e ON f.ecurrency_id = e.id ".
					" WHERE f.currency_type = '$type'".
					" ORDER BY f.id ASC LIMIT $page_start, $rows_per_page";
		$res = $db->get_results($strSQL);
		return $res;
	}
	
	
	public function saveFee($db, $info) {
    	$sql=sprintf(
					"INSERT INTO %s(ecurrency_id,bank_id,currency_type,fee_percent,bank_fee,bank_currency,".
					"amount_litmit,amount_currency,notes) " .
					"VALUES('%s','%s','%s','%s','%s','%s','%s','%s','%s')",
    				TBL_CURRENCY_FEE, 
    				$info['ecurrency_id'],
					$info['bank_id'],
    				$info['currency_type'],
					$info['fee_percent'],
					$info['bank_fee'],
					$info['bank_currency'],
					$info['amount_litmit'],
					$info['amount_currency'],
					$info['notes']);
        		
    	$res = $db->query($sql);
		$id = -1;
		if($res == true) {	
			$id=$db->insert_id;
			return $id;
		}	
    	else
    		return $id;
    }
	

}
?>